/**
 * @ClassName LC747
 * @Author ykx
 * @Date 2024/7/6 22:57
 * @Version 1.0
 */
public class LC747 {
    public int dominantIndex(int[] nums) {
        int max = nums[0], index = 0;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] > max) {
                max = nums[i];
                index = i;
            }
        }

        for (int i = 0; i < nums.length; i++) {
            if (i == index) {
                continue;
            } else {
                if (nums[i] * 2 > max) {
                    return -1;
                }
            }
        }

        return index;
    }

    public static void main(String[] args) {

    }

}

